package org.sucri.servlet.controller;

import org.directwebremoting.annotations.DataTransferObject;
import org.directwebremoting.annotations.RemoteProperty;
import org.sucri.floxs.Tools;

import java.io.Serializable;
import java.util.List;
import java.util.Arrays;

/**
 * Created by IntelliJ IDEA.
 * User: Wen Yu
 * Date: Dec 24, 2007
 * Time: 10:08:59 PM
 * To change this template use File | Settings | File Templates.
 */
@DataTransferObject
public class ListRange<T> implements Serializable
{
  public ListRange()              { super(); }
  public ListRange(List s)        { super(); setData(s); setTotalSize(s.size()); }
  public ListRange(List s, int z) { super(); setData(s); setTotalSize(z); }

  @RemoteProperty
  private T[] data;
  @RemoteProperty
  private int totalRows;
  @RemoteProperty
  private String message;

  //accessors for both properties
  public T[] getData() { return data; }
  public int getTotalSize() { return totalRows; }

  public void setData(T[] s) { data = s; }
  public void setData(List s)
  {
    if (!Tools.good(s)) return;

    data = (T[] )s.toArray();
    //data = new Payload[s.size()];
    //for (int i = 0; i < s.size(); i++) data[i] = new Payload("u", s.get(i));
  }
  public void setTotalSize(int s) { totalRows = s; }
}